# -*- coding: utf-8 -*-
#


from sippeer.utils.logutil import logger

from threading import Thread



class ServiceSession(Thread):
    """
    Running service between two peers.
    1. It is initialized using Service and SIPSession.
    The relationship between SIPSession and ServiceSession is 1 to n,
    and designed using Observer Design Pattern which provided register and publish mechanism.
    2. Inherit Thread shows it's running state and it will use Service class to do the real operation.
    """
    
    def __init__(self, service, sip_session):
        
        Thread.__init__(self);
        
        try:
            if service == None or sip_session == None:
                logger.error("ServiceSession::init(): service or sipsession is None")
                raise InitError
        except InitError:
            return
        
        self._service = service
        self._sipSession = sip_session
        self._sessionParam = None
        
        self._serviceName = ""
        self._serviceSessionID = self._sipSession.generateServiceSessionID()
        
        
    def updateSessionParam(self, session_param):
        pass
    
    def run(self):
        pass
    
    def getService(self):
        return self._service
    
    def getServiceName(self):
        return self._serviceName
    
    def getSIPSession(self):
        return self._sipSession
    
    def getServiceSessionID(self):
        return self._serviceSessionID
    
    
    
    
        